/**  
 * All rights Reserved, Designed By www.tydic.com
 * @Title:  TradesController.java   
 * @Package com.axin.controller   
 * @Description:    TODO(用一句话描述该文件做什么)   
 * @author: axin     
 * @date:   2019年5月21日 下午10:19:57   
 * @version V1.0 
 * @Copyright: 2019 www.hao456.top Inc. All rights reserved. 
 */
package com.axin.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.axin.common.entity.DataGridResult;
import com.axin.common.entity.PageObject;
import com.axin.entity.HbTrades;
import com.axin.entity.HbUser;
import com.axin.service.TradesService;

/**   
 * @Description: TODO 
 * @ClassName:  TradesController
 * @author:  Axin 
 * @date:   2019年5月21日 下午10:19:57   
 * @Copyright: 2019 www.hao456.top Inc. All rights reserved. 
 */
@Controller
@RequestMapping("/trades")
public class TradesController {

	
	@Autowired
	private TradesService tradesService;
	
	@RequestMapping(value="/buyList",method=RequestMethod.GET)
	@ResponseBody
	public DataGridResult buyList(HbTrades trades,PageObject page,HttpServletRequest request){
		HbUser user =(HbUser)request.getAttribute("user");
		trades.setTradeDirect("1");
		DataGridResult result = this.tradesService.getListByParam(page, trades, user.getId());
		return result;
	}
	
	
	@RequestMapping(value="/sellList",method=RequestMethod.GET)
	@ResponseBody
	public DataGridResult sellList(HbTrades trades,PageObject page,HttpServletRequest request){
		HbUser user =(HbUser)request.getAttribute("user");
		trades.setTradeDirect("2");
		DataGridResult result = this.tradesService.getListByParam(page, trades, user.getId());
		return result;
	}
	
	@RequestMapping(value="/list",method=RequestMethod.GET)
	@ResponseBody
	public DataGridResult list(HbTrades trades,PageObject page,HttpServletRequest request){
		HbUser user =(HbUser)request.getAttribute("user");
		String sort = (String)request.getParameter("sort");
		String order = (String)request.getParameter("order");
		
		DataGridResult result = this.tradesService.getGroupListByParam(page, trades, sort,order,user.getId());
		return result;
	}
}
